package org.jprobe.ui;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.Toolkit;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.security.Permission;

import javax.swing.JFrame;
/**
 *
 * The Main access to startup the application
 *
 * @author Hussain Al-Mutawa
 * @version 2.0
 * @since 1.0
 */
@SuppressWarnings("serial")
public final class Main extends JFrame {

	/** initializes the Main frame and make it ready **/
	private Main(){
		super("jProbe-2.0");
		getContentPane().setLayout(new BorderLayout());
		getContentPane().add(new Header(),BorderLayout.NORTH);
		getContentPane().add(new ProjectView(),BorderLayout.CENTER);
		setPreferredSize(new Dimension(658,500));
		setSize(getPreferredSize());
		setMinimumSize(getPreferredSize());

		final Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
		setLocation((dim.width-getSize().width)/2,(dim.height-getSize().height)/2);
		setDefaultCloseOperation(HIDE_ON_CLOSE);
		pack();
		addWindowListener(new WindowAdapter() {
			@Override
			public void windowClosed(WindowEvent e) {
				System.exit(8396957);
			}
		});
	}

	/**
	 * main entry to the application
	 * @param args
	 */
	public static void main(final String[] args) {
		
		System.setSecurityManager(new SecurityManager(){
			@Override
	        public void checkPermission(Permission perm) 
	        {
	                // allow anything.
	        }
	        @Override
	        public void checkPermission(Permission perm, Object context) 
	        {
	                // allow anything.
	        }
			@Override
			public void checkExit(int status){
				super.checkExit(status);
				if(status!=8396957){
					throw new SecurityException();
				}
			}
		});
		new Main().setVisible(true);
	}
}
